﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Ls.Data;

namespace Ls.Web.Admin
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddCommandLine(args)   //添加对命令参数的支持
              .Build();

            var keys = DbProviderFactories.GetProviderInvariantNames();
            foreach (var k in keys)
            {
                Log.Debug(k);
            }
            //var f = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
            // BuildWebHost(args).Run();
            var host = new WebHostBuilder() 
               .UseConfiguration(config)
               .UseKestrel()
               .UseContentRoot(Directory.GetCurrentDirectory()) 
               .UseIISIntegration()
               .UseStartup<Startup>()
               .Build();
            host.Run();
        }

        //public static IWebHost BuildWebHost(string[] args) =>
        //    WebHost.CreateDefaultBuilder(args)
        //        .UseStartup<Startup>()
        //        .Build();
    }
}
